﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Show_Picture : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string sID = Request.Params["id"].ToString();
        if (!Page.IsPostBack)
        {
            AppSettingsReader _configReader = new AppSettingsReader();
            SqlConnection conn = new SqlConnection(_configReader.GetValue("Main.ConnectionString", typeof(string)).ToString());

            string strSql = "select * from t_Album where Album_ID='"+sID+"'";//这里假设获取id为5的图片
            SqlCommand cmd = new SqlCommand(strSql, conn);
            conn.Open();
            SqlDataReader ndrReader = cmd.ExecuteReader();
            byte[] ss = null;
            if (ndrReader.Read())
            {
                ss = (byte[])ndrReader["Album_Content"];
            }
            ndrReader.Close();
            if (ss != null)
            {
                Response.ContentType = "application/octet-stream";
                Response.BinaryWrite(ss);
            }
        }
    }
}
